package com.example.kotlinlearndemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.kotlinlearndemo.databinding.ActivityMain3Binding
import com.opensource.svgaplayer.SVGADrawable
import com.opensource.svgaplayer.SVGAParser
import com.opensource.svgaplayer.SVGAVideoEntity


class MainActivity3 : AppCompatActivity() {
    lateinit var binding: ActivityMain3Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMain3Binding.inflate(layoutInflater)

        setContentView(binding.root)

        val parser = SVGAParser.shareParser()
        parser.init(this)

        parser.decodeFromAssets("test.svga", object : SVGAParser.ParseCompletion {
            override fun onComplete(videoItem: SVGAVideoEntity) {
                binding.test.apply {
                    val drawable = SVGADrawable(videoItem)

                    setImageDrawable(drawable)
                    stepToFrame(0,false)
                    //startAnimation()
                }
            }

            override fun onError() {
            }

        })
    }
}